package etc.com.market;
import java.util.ArrayList;

import etc.com.market.SpecifyProduct;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class FvrGrp extends ActivityGroup {
	
	 private ArrayList<View> history;  
     private ArrayList<String> strHistory;
     
     String str;
     Intent intent;
     View view;
	public static FvrGrp group;  
	  public boolean isFirstLoad = true;
	  
    @Override
	protected void onCreate(Bundle savedInstanceState) {  
          super.onCreate(savedInstanceState);  
          this.history = new ArrayList<View>();   
          this.strHistory = new ArrayList<String>();
          group = this;  
        //  (MarketSystem)getApplicationContext();
          
      	intent = new Intent(this, SpecifyProduct.class);
		intent.putExtra("mode", "favorite");
			
			 
		View view = getLocalActivityManager().startActivity("favorite", intent
                                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))  
                                            .getDecorView();  
		overridePendingTransition(R.anim.fadein,
                R.anim.fadeout);
	      // Replace the view of this ActivityGroup  
	      replaceView(view, "SermonAct");  
  
       }  
  
    public void replaceView(View v, String viewName) {  
              
        history.add(v);  
        strHistory.add(viewName);
        setContentView(v);  
    }  
  
    public void ShowMainPage(){
      	 if(history.size() > 1){
      		 if(history.size() == 2){
//      			 SermonDetailAct.seft.HideKeyBoard();
      		 }
   	    	history.remove(history.size()-1);
   	        setContentView(history.get(0));
      	 }
      }
    
    public void back() {  
        if(history.size() > 0) {
        	if(history.size()==1)
            {
            	startActivity(MarketApp.seft.getIntent());
            	finish();
            	overridePendingTransition(R.anim.fadein,
                        R.anim.fadeout);
            	return;
            }
        	history.remove(history.size()-1);
            setContentView(history.get(history.size()-1));
        }else {  
            finish();  
            overridePendingTransition(R.anim.fadein,
                    R.anim.fadeout);
        }  
    }  
  
     
    @Override
	public void onBackPressed() {  
	   FvrGrp.group.back();  
        return;  
    }
   
}
